package com.lotusfall.mapper;

import com.github.pagehelper.PageInfo;
import com.lotusfall.pojo.HouseResource;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface HouseResourcesMapper {
    @Insert("insert into tb_house_resources " +
            "values(null,#{title},#{estateId},#{buildingNum}," +
            "#{buildingUnit},#{buildingFloorNum},#{rent}," +
            "#{rentMethod},#{paymentMethod},#{houseType}," +
            "#{coveredArea},#{floor},#{orientation}," +
            "#{decoration},#{facilities},#{pic},#{houseDesc}," +
            "#{contact},#{mobile},#{time},#{propertyCost},#{created},#{updated})")
    int saveHouseResources(HouseResource houseResource);

    @Select("select * from tb_house_resources limit #{page},#{pageSize}")
    List<HouseResource> queryHouseResourcesList(int page, int pageSize);

    @Select("select * from tb_house_resources where id = #{id}")
    HouseResource queryHouseResourcesById(Long id);

    @Update("update tb_house_resources set title = #{title},estate_id#{estateId},building_num =#{buildingNum}," +
            "building_unit = #{buildingUnit},building_floor_num = #{buildingFloorNum},rent = #{rent}," +
            "rent_method = #{rentMethod},payment_method = #{paymentMethod},house_type = #{houseType},"+
            "cover_area = #{coveredArea},user_area = #{userArea},floor = #{floor},orientation = #{orientation},"+
            "decoration = #{decoration},facilities = #{facilities},pic = #{pic},houseDesc = #{houseDesc}," +
            "contact = #{contact},mobile = #{mobile},time = #{time},propertyCost = #{propertyCost},created = #{created},updated = #{updated})")
    int updateHouseResource(HouseResource houseResources);


    @SelectProvider(type = HouseDynaSqlProviderBuilder.class, method = "selectHouse")
    List<HouseResource> queryHouseResourcesListByCondition(Integer page, Integer pageSize, Integer type, Integer ori, Integer area, Integer rent);
}
